const global = require('../global')
const transform = require('../transform')

module.exports = async (ctx) => {
  const { request } = ctx
  const url = decodeURIComponent(request.url)
  const content = transform.implement(url, url, url.split('/').filter((u) => !!u))
  if (content) {
    return ctx.body = content
  } else {
    await ctx.render('docs', {
      links: global.links,
    })
  }
}
